home *** CD-ROM | disk | FTP | other *** search
/ Enciclopedia Del Perro / Enciclopedia Del Perro.iso / win / tfw115c1 / tfw.5 / STOPWATC.SLT < prev    next >
Text File  |  1996-04-15  |  3KB  |  76 lines

  1. /****************************************************************/
  2. /*                                                              */
  3. /*  Demo of how to use timer-based functions in SALT scripts,   */
  4. /*  like in this simple stopwatch.                              */
  5. /*                                                              */
  6. /*                   Copyright 1995 deltaComm Development, Inc. */
  7. /*                                                              */
  8. /****************************************************************/
  9.  
  10.  
  11. main()
  12. {
  13. int t, tu, finit;
  14. tu = finit = 0;  
  15.  
  16. prints("Press any key to start timer.");
  17. inkeyw();
  18.  
  19. t = timer_start(100);                     // Start with a 10 second count
  20.  
  21. alarm(1);
  22. status_wind("And they're off!", 5);       // Alert user that timer is started
  23. prints("Press a key to halt timer.");
  24. while (not finit)                         // set up a loop, seemingly endless
  25.   {
  26.    if (inkey())                           // if the user presses a key, then
  27.      finit = 1;                           // set "finit" to true so loop ends
  28.  
  29.    if (tu ^ time_up(t))                   // Check for elapsed timer
  30.      {
  31.       tu = time_up(t);                    // Disable the elapsed timer msg
  32.       prints("Some time today?...");      //    if the timer's up.
  33.       playwave("jeop.wav");               // Here's our host, Alex Trebeck!
  34.      }
  35. //   tone((t*5)+100, 1);                  // Uncomment for a noiser timer
  36.   }
  37.  
  38. printsc("That was ");                     // Show user how much time elapsed
  39. tu=timer_total(t);
  40. printn(tu);
  41. prints(" tenths of a second.");
  42.  
  43. timer_restart(t, 0);                      // restart timer where it left off
  44. prints("One more time(r).  <g>");         // and go again....
  45.  
  46. inkeyw();                                 // Wait for keypress
  47.  
  48. printsc("Total time: ");
  49. printn(tu+timer_total(t));
  50. prints(" tenths of a second.");
  51.  
  52. timer_free(t);                            // Free timer for use by
  53.                                           // another application
  54.  
  55. t=curtime();
  56.  
  57. prints();                                 // Finally, do a little manipulation
  58. printsc("Time is: ");                     // on the output of "curtime" to
  59. printn(thour(t));                         // display the current time and date
  60. printsc(":");                             // on screen in a nice format.
  61. if (tmin(t)<10) printsc("0");
  62. printn(tmin(t));
  63. printsc(":");
  64. if (tsec(t)<10) printsc("0");
  65. printn(tsec(t));
  66. prints();
  67. printsc("Date: ");
  68. printn(tmonth(t));
  69. printsc("-");
  70. printn(tday(t));
  71. printsc("-");
  72. printn(tyear(t));
  73. prints();
  74.  
  75. }
  76.